import os
import queue
import sys
import threading

import redis
import urllib3

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

# 设置标准输出为无缓冲
sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', buffering=1)  # 行缓冲

Q = queue.Queue()
R = redis.Redis(host='localhost', port=6379, db=3)

# 创建一个互斥锁  互斥发送回答问题的请求
LOCK = threading.Lock()

# 采集间隔时间 分钟  0 表示不限制收到信息就采集
MINUTE_GAP = 0

HEADERS = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36",
    "Host": "www.douban.com",
    "Connection":"Close"
}

# 隧道域名:端口号
tunnel = "u705.kdltps.com:15818"

# 用户名密码方式
username = "t14920023015118"
password = "lny2ogcg"

PROXIES = {
    "http": "http://%(user)s:%(pwd)s@%(proxy)s/" % {"user": username, "pwd": password, "proxy": tunnel},
    "https": "http://%(user)s:%(pwd)s@%(proxy)s/" % {"user": username, "pwd": password, "proxy": tunnel}
    }

DEBGUG = False

if  DEBGUG:
    # PROXIES = {
    #     "http": "http://127.0.0.1:9000",
    #     "https": "http://127.0.0.1:9000"
    # }
    COOKIE_PATH = r"D:\PycharmProjects\douban\cookies.txt"
    ANWSER_PATH = r"D:\PycharmProjects\douban\answer.txt"
else:
    COOKIE_PATH = r"/home/ladybug/douban/cookies.txt"
    ANWSER_PATH = r"/home/ladybug/douban/answer.txt"

# 平台
PLATFORM_LIS = ["京东", "淘宝","拼多多","唯品会"]

# 平台解析接口
URL_MAP = {
        "京东": "http://cgi-bin.lottefuture.com/python/jd-goods-query.php",
        "淘宝": "http://cgi-bin.lottefuture.com/python/taobao-goods-query.php",
        "拼多多":"http://cgi-bin.lottefuture.com/python/pdd-goods-query.php",
        "唯品会":"http://cgi-bin.lottefuture.com/python/vipshop-goods-query.php",
    }

